home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-11 | 8.1 KB | 442 lines | [TEXT/CWIE] |
- // CModalRadios.cp -- dialog methods
-
- #include "CModalRadios.h"
-
- #include <UEnvironment.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <LStream.h>
- #include <LTabGroup.h>
- #include <LPushButton.h>
- #include <LAMPushButtonImp.h>
- #include <LGAPushButtonImp.h>
- #include <LRadioGroupView.h>
- #include <LRadioButton.h>
- #include <LAMControlImp.h>
- #include <LGARadioButtonImp.h>
- #include <LTextGroupBox.h>
- #include <LAMControlViewImp.h>
- #include <LGATextGroupBoxImp.h>
- #include <CustomControls.h>
- #include <LBevelButton.h>
- #include <LAMBevelButtonImp.h>
- #include <LGABevelButtonImp.h>
- #include <LTextButton.h>
- #include <CTextUtils.h>
-
- #include "DModalRadiosData.h"
- #include "EverythingCmds.h"
- #include <PP_Messages.h>
-
-
- #define PPob_ModalRadiosID 210
- #define RidL_ModalRadiosID 210
-
- Boolean CModalRadios::sIsRegistered = false;
-
- //----------
- CModalRadios* CModalRadios::CreateModalRadios (
- LCommander* inSuperCommander,
- CommandT inCommand,
- DModalRadiosData* inData)
- {
- if (!sIsRegistered) {
- RegisterClass ();
- }
- CModalRadios* dlog;
- dlog = ((CModalRadios *)LWindow::CreateWindow(PPob_ModalRadiosID, inSuperCommander));
- dlog->mCommand = inCommand;
- dlog->SetFromData (inData);
-
- return dlog;
- }
-
- //----------
- #define RegisterClasses(AbstractClass,AMImpClass,GAImpClass) \
- RegisterClass_(AbstractClass); \
- if (useAppearance) { \
- RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID); \
- } else { \
- RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID); \
- }
-
- //----------
- void CModalRadios::RegisterClass ()
- {
- Boolean useAppearance = UEnvironment::HasFeature (env_HasAppearance);
-
- RegisterClass_(CModalRadios);
-
- // register the pane classes we use
- RegisterClasses (LPushButton, LAMPushButtonImp, LGAPushButtonImp);
- RegisterClass_(LRadioGroupView);
- RegisterClasses (LRadioButton, LAMControlImp, LGARadioButtonImp);
- RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
- RegisterClasses (CRadioButton, CustomControlImp, CustomControlImp);
- RegisterClasses (LBevelButton, LAMBevelButtonImp, LGABevelButtonImp);
- RegisterClass_(LTextButton);
-
- sIsRegistered = true;
- }
-
- //----------
- CModalRadios::CModalRadios (
- LStream* inStream)
- : LGADialog (inStream)
- {
- mData = nil;
- }
-
- //----------
- CModalRadios::~CModalRadios()
- {
- delete mData;
- }
-
- //----------
- // This member function gets called once the containment hierarchy that contains
- // this pane has been built. It gives us a chance to get data members for
- // interesting subviews, and to do other operations now that our subviews exist.
- void CModalRadios::FinishCreateSelf()
- {
- LGADialog::FinishCreateSelf();
-
- mOKButton = (LPushButton*) FindPaneByID ('OK ');
-
- mRadioGroupGroup = (LRadioGroupView*) FindPaneByID ('Radp');
-
- mStandardRadio = (LRadioButton*) FindPaneByID ('Stad');
-
- mGroupGroup = (LRadioGroupView*) FindPaneByID ('Grop');
-
- mGraphicGroup = (LRadioGroupView*) FindPaneByID ('Grac');
-
- mStopRadio = (CRadioButton*) FindPaneByID ('Stop');
-
- mGoRadio = (CRadioButton*) FindPaneByID ('Go ');
-
- mBevelGroup = (LRadioGroupView*) FindPaneByID ('Bevl');
-
- mRadioButtonRadio = (LBevelButton*) FindPaneByID ('Radn');
-
- mRadioButton2Radio = (LBevelButton*) FindPaneByID ('Rad2');
-
- mTextGroup = (LRadioGroupView*) FindPaneByID ('Text');
-
- mNameRadio = (LTextButton*) FindPaneByID ('Name');
-
- mKindRadio = (LTextButton*) FindPaneByID ('Kind');
-
- mSizeRadio = (LTextButton*) FindPaneByID ('Size');
-
-
- UReanimator::LinkListenerToControls(this, this, RidL_ModalRadiosID);
- // the purpose is to "connect" self to whatever controls
- // that we want to "listen" to
-
- // any additional initialization for your dialog:
-
- }
-
- //----------
- void CModalRadios::SetFromData (
- DModalRadiosData* inData)
- {
- mData = inData;
- mData->AddListener (this);
-
- mRadioGroupGroup->SetValue (mData->GetRadioGroup2 ());
- mGroupGroup->SetValue (mData->GetGroup2 ());
- mGraphicGroup->SetValue (mData->GetGraphic3 ());
- mBevelGroup->SetValue (mData->GetBevel2 ());
- mTextGroup->SetValue (mData->GetText2 ());
- }
-
- //----------
- DModalRadiosData* CModalRadios::GetData ()
- {
-
- return mData;
- }
-
- //----------
- void CModalRadios::DataChanged (
- long inDataID)
- {
- StopListening ();
-
- if (inDataID == idRadioGroup2) {
- mRadioGroupGroup->SetValue (mData->GetRadioGroup2 ());
- }
- if (inDataID == idGroup2) {
- mGroupGroup->SetValue (mData->GetGroup2 ());
- }
- if (inDataID == idGraphic3) {
- mGraphicGroup->SetValue (mData->GetGraphic3 ());
- }
- if (inDataID == idBevel2) {
- mBevelGroup->SetValue (mData->GetBevel2 ());
- }
- if (inDataID == idText2) {
- mTextGroup->SetValue (mData->GetText2 ());
- }
-
- StartListening ();
- }
-
- //----------
- void CModalRadios::ListenToMessage (
- MessageT inMessage,
- void *ioParam)
- {
- switch (inMessage) {
- case msg_OK:
- GetSuperCommander()->ProcessCommand(-mCommand, this);
- break;
-
- case msg_Cancel:
- DoClose();
- break;
-
- case msgDataChanged:
- DataChanged ((long)ioParam);
- break;
-
-
- default:
- ; // do something
- break;
- }
- }
-
- //----------
- Boolean CModalRadios::ObeyCommand (
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true;
-
- if (inCommand < 0) {
- // modal dialog has finished
-
- switch (-inCommand) {
- }
-
- } else {
- switch (inCommand) {
-
- default:
- cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
- break;
- }
- }
-
- return cmdHandled;
- }
-
- //----------
- void CModalRadios::FindCommandStatus (
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LGADialog::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- // following functions will be obsoleted
- // retained only for backwards compatibility
- //----------
- Int32
- CModalRadios::GetRadioGroupGroupChoice ()
- {
- return mRadioGroupGroup->GetCurrentRadioID ();
- }
-
- void
- CModalRadios::SetRadioGroupGroupChoice (
- Int32 choice)
- {
- mRadioGroupGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModalRadios::GetStandardValue ()
- {
- return mStandardRadio->GetValue ();
- }
-
- void
- CModalRadios::SetStandardValue (
- Boolean inValue)
- {
- mStandardRadio->SetValue (inValue);
- }
-
- //----------
- Int32
- CModalRadios::GetGroupGroupChoice ()
- {
- return mGroupGroup->GetCurrentRadioID ();
- }
-
- void
- CModalRadios::SetGroupGroupChoice (
- Int32 choice)
- {
- mGroupGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Int32
- CModalRadios::GetGraphicGroupChoice ()
- {
- return mGraphicGroup->GetCurrentRadioID ();
- }
-
- void
- CModalRadios::SetGraphicGroupChoice (
- Int32 choice)
- {
- mGraphicGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModalRadios::GetStopValue ()
- {
- return mStopRadio->GetValue ();
- }
-
- void
- CModalRadios::SetStopValue (
- Boolean inValue)
- {
- mStopRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModalRadios::GetGoValue ()
- {
- return mGoRadio->GetValue ();
- }
-
- void
- CModalRadios::SetGoValue (
- Boolean inValue)
- {
- mGoRadio->SetValue (inValue);
- }
-
- //----------
- Int32
- CModalRadios::GetBevelGroupChoice ()
- {
- return mBevelGroup->GetCurrentRadioID ();
- }
-
- void
- CModalRadios::SetBevelGroupChoice (
- Int32 choice)
- {
- mBevelGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModalRadios::GetRadioButtonValue ()
- {
- return mRadioButtonRadio->GetValue ();
- }
-
- void
- CModalRadios::SetRadioButtonValue (
- Boolean inValue)
- {
- mRadioButtonRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModalRadios::GetRadioButton2Value ()
- {
- return mRadioButton2Radio->GetValue ();
- }
-
- void
- CModalRadios::SetRadioButton2Value (
- Boolean inValue)
- {
- mRadioButton2Radio->SetValue (inValue);
- }
-
- //----------
- Int32
- CModalRadios::GetTextGroupChoice ()
- {
- return mTextGroup->GetCurrentRadioID ();
- }
-
- void
- CModalRadios::SetTextGroupChoice (
- Int32 choice)
- {
- mTextGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModalRadios::GetNameValue ()
- {
- return mNameRadio->GetValue ();
- }
-
- void
- CModalRadios::SetNameValue (
- Boolean inValue)
- {
- mNameRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModalRadios::GetKindValue ()
- {
- return mKindRadio->GetValue ();
- }
-
- void
- CModalRadios::SetKindValue (
- Boolean inValue)
- {
- mKindRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModalRadios::GetSizeValue ()
- {
- return mSizeRadio->GetValue ();
- }
-
- void
- CModalRadios::SetSizeValue (
- Boolean inValue)
- {
- mSizeRadio->SetValue (inValue);
- }
-
-